/**
 * Created by Liutong on 7/31/15.
 */
$(document).ready(function(){
    var total = parseInt($("#total").val());
    var pageSize = parseInt($("#pageSize").val());
    var currentPage = $("#currentPage").val();
    var totalPages = total/pageSize < 1 ? 1 : Math.ceil(total/pageSize);
    $('#pagination,#pagination_bottom').bootstrapPaginator({
        alignment:"left",
        numberOfPages: 10,
        currentPage: currentPage,
        totalPages:  totalPages,
        onPageClicked: function(event, originalEvent, type, page){
            $("#currentPage").val(page);

            var form = $("#myForm");
            if(form){
                form.submit();
            } else{
                $("form").submit();
            }
        }
    });

    $("#paginationInfo,#paginationInfo_bottom").html("共"+total+"条记录 "+currentPage+"/"+totalPages);
});
